/*! jMenu.js
 * ================
 * AdminLTE Menu Creator
 * dependence on AdminLTE 2.1.2
 *
 * @Author  zengzhijun
 * @Support <http://www.almsaeedstudio.com>
 * @Email   <zzjvslove@qq.com>
 * @version 1.0.0
 * @license MIT <http://opensource.org/licenses/MIT>
 */
var TgfRequest = (function () {

    var defOpts = {
        url:'/',
        type:'post',
        dataType: 'json',
        traditional: false,
        successCode: 200,
        timeout: 30000
    };
    
    function req(options, callback, completeCb, errCb) {
        var options = $.extend(defOpts, options);
        $.ajax({
            url: options.url,
            type: options.type || 'post',
            dataType: options.dataType || 'json',
            data: options.where || {},
            beforeSend: function (jqXHR, settings) {

            },
            success:function(res) {
                if(typeof(callback) == 'function') {
                    callback(res);
                }
            },
            error:function (jqXHR, status) {
                if(typeof errorCb == 'function') {
                    errorCb(jqXHR, status);
                }
            },
            complete: function (jqXHR) {
                if(typeof completeCb == 'function') {
                    completeCb(jqXHR, status);
                }
            }
        });
    }








    //
    return {
        ajax: ajax,
        post:post,
        get:get,
        req:req
    }
})();